#ifndef CLI.PY
#define CLI.PY
#!/usr/bin/python
#-*- coding: utf-8 -*-
# PyQtSozluk Team :P
#

from optparse import OptionParser
from sys import exit, argv
from pysozlukglobals import version as progversion
from database import pysozlukDatabase
from online import onlineDatabase

def search(keyword, gui_stat, online_stat):
    print "Search the word : ", keyword
    if gui_stat:
        print "Use graphical interface"
    if online_stat:
        print "Use online search only"
    exit()

def smartsearch(keyword, gui_stat):
    print "Smart search: ", keyword
    if gui_stat:
        print "Use graphical interface: "
    exit()

def main():

    gui_enabled = 0
    online = 0

    use = """pysozluk-cli [options] arg
            sample usage:
            pysozluk-cli -s word
            pysozluk-cli -s -g word
            pysozluk-cli --smart -g word  """

    desc = "PyQtSozluk Command Line Interface"

    parser = OptionParser(usage=use, version=progversion, description=desc)
    parser.add_option("-g", "--gui", help="Show translated word in gui", action="store_true", dest="gui_status", default=False)
    parser.add_option("-o", "--online", help="Online search", action="store_true", dest="online_search", default=False)
    parser.add_option("-m", "--smart", help="Translate in smart mode", action="store", dest="smartword")
    parser.add_option("-s", "--search", help="Translate corresponding word", action="store", dest="searchword")

    (options, args) = parser.parse_args()
    if not args and not options: parser.exit()

    if options.gui_status:
        gui_enabled = 1

    if options.online_search:
        online = 1

    if options.smartword == None and options.searchword != None:
        search(options.searchword, gui_enabled, online)
    elif options.smartword != None and options.searchword == None:
        smartsearch(options.smartword, gui_enabled) 

if __name__ == "__main__":
    main()

#endif // CLI.PY
